package com.boge.parse.ioByte;

import java.nio.charset.Charset;

import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolCodecFactory;
import org.apache.mina.filter.codec.ProtocolDecoder;
import org.apache.mina.filter.codec.ProtocolEncoder;

/**
 * 二进制 过滤器
 * @author boge
 *
 */
public class IoByteProtocolCodecFilter implements ProtocolCodecFactory {

	private IoByteProtocolDecoder protocolDecoder;
	private IoByteProtocolEncoder protocolEncoder;
	
	public IoByteProtocolCodecFilter() {
		this(Charset.defaultCharset());
	}
	
	public IoByteProtocolCodecFilter(Charset charset) {  
		protocolDecoder = new IoByteProtocolDecoder(charset);
		protocolEncoder = new IoByteProtocolEncoder();
    }
	
	@Override
	public ProtocolEncoder getEncoder(IoSession session) throws Exception {
		return protocolEncoder;
	}

	@Override
	public ProtocolDecoder getDecoder(IoSession session) throws Exception {
		return protocolDecoder;
	}

}
